Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Patient Service and Implement CRUD operations #45

Merged
merged 6 commits into from
Jun 20, 2024

Conversation

cgolemme
Copy link
Contributor

@cgolemme cgolemme commented Jun 18, 2024

Summary

This PR adds endpoints to the bulk-export-server to handle operations related to Patients. Adds operations to create, get, update and delete patients on the server. This PR also adds Group delete endpoint. [host]/Patient and [host]/Group now correctly return a searchset as per fhir spec, https://hl7.org/fhir/R4/http.html#search.

JIRA Issue

New behavior

bulk-export-server now has CRUD operations for Patients

  • GET : [host]/Patient
  • GET : [host]/Patient/[patientId]
  • POST : [host]/Patient
  • PUT : [host]/Patient/[patientID]
  • DELETE : [host]/Patient/[patientID]

Now has new delete operation for Group

  • DELETE : [host]/Group/[groupID]

Endpoints that find multiple Patients or Groups from the server, GET : [host]/Patient and GET : [host]/Group, now return a searchset object instead of a json list of fhir Patient or Group objects.

Code changes

  • .eslintrc.json and .prettierignore were changed to add ecqm-content-r4-2021 to the excluded folders because they were causing warnings with eslint and prettier.
  • src/server/app.js was changed to add the new patient endpoints and new group endpoint to the server.
  • src/services/group.service.js: updated some comments to be more specific, wrapped the /Group get endpoint in a search set object, added new function for DELETE endpoint.
  • src/services/patient.service.js was created to implement functions that will interact with the database to fulfill the CRUD operations requested when a user accesses the endpoints for Patients.
  • test/fixtures/updatedTestPatient.json was created to test the PUT endpoint.
  • test/services/patient.service.test.js are tests for the patient.service.js operations that follows closely from the group.service.test.js file.
  • src/util/bundleUtils.js: created to generate the searchset bundle object that wraps the response from the server for the /Patient and /Group endpoints.
  • src/util/mongo.controller.js: added a default projection to filter out mongo-generated ids from the server's responses to all operations.
  • test/services/group.service.test.js: changed /Group test to interact with new searchset response from server

Testing guidance

  • run npm run check
  • Check that prettier and eslint cause no errors
  • Check that all the tests pass
  • Test endpoints on Insomnia

Copy link

github-actions bot commented Jun 18, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
76.59% (+1.7% 🔼)
543/709
🟡 Branches
62.58% (+0.94% 🔼)
189/302
🟡 Functions
75.44% (+2.8% 🔼)
86/114
🟡 Lines
76.9% (+1.71% 🔼)
536/697
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / patient.service.js
96.55% 87.5% 100% 96.55%

Test suite run success

89 tests passing in 8 suites.

Report generated by 🧪jest coverage report action from 957a8ab

@elsaperelli elsaperelli self-requested a review June 19, 2024 14:26
@elsaperelli elsaperelli self-assigned this Jun 19, 2024
Copy link
Collaborator

@elsaperelli elsaperelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

The only thing I would change in the future (not a big deal for this one at all) but just make sure that you include in the testing guidance to try out the new endpoints in Insomnia! (This should be kinda obvious but good to add)

Copy link
Contributor

@hossenlopp hossenlopp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The listing of all patients is returning a JSON Array this should be a searchset Bundle instead. See https://hl7.org/fhir/R4/http.html#search for more info.

Additionally we should have the internal mongo _ids projected out of the responses.

@cgolemme
Copy link
Contributor Author

I made the requested changes. One potentially weird thing that I did was call const found = await findResourceById(request.params.groupId, 'Group'); in the group and patient delete functions in order to correctly return the 404 that we want because there is nowhere in the call stack of removeReasource that could throw an error the resource to remove is not found.

Copy link
Collaborator

@elsaperelli elsaperelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small comment but otherwise almost good to go!

src/util/mongo.controller.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@elsaperelli elsaperelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm! Way to be flexible!!

@hossenlopp hossenlopp merged commit c006d6e into main Jun 20, 2024
4 checks passed
@elsaperelli elsaperelli deleted the TOCOSTRAT-1506-create-patient-service branch June 20, 2024 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants